﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TogheterWeBuyIt.Models.Usuario>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Cadastro
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
    function radioChecked(isCPF) {

        document.getElementById("RadioButtonCPF").checked = isCPF;
        document.getElementById("RadioButtonCNPJ").checked = !isCPF;

        if (isCPF) {
            document.getElementById("CNPJ").disabled = "disabled";
            document.getElementById("CPF").disabled = null;
        } else {
            document.getElementById("CNPJ").disabled = null;
            document.getElementById("CPF").disabled = "disabled";
        }

    }
</script>

    <h2>Cadastro</h2>
    <% using (Html.BeginForm()) {%>
        <%= Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Seus dados:</legend>
                        
            <div class="editor-label">
                <input type="radio" id="RadioButtonCPF" onclick="radioChecked(true)" />
                <%= Html.LabelFor(model => model.CPF) %>
            </div>
            <div class="editor-field">
                <input type="text" id="CPF" disabled="disabled" />
                <%= Html.ValidationMessageFor(model => model.CPF) %>
            </div>
            
            <div class="editor-label">
                <input type="radio" id="RadioButtonCNPJ" onclick="radioChecked(false)" />
                <%= Html.LabelFor(model => model.CNPJ) %>
            </div>
            <div class="editor-field">
                <input type="text" id="CNPJ" disabled="disabled" />
                <%= Html.ValidationMessageFor(model => model.CNPJ) %>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Nome) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Nome) %>
                <%= Html.ValidationMessageFor(model => model.Nome) %>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Login) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Login) %>
                <%= Html.ValidationMessageFor(model => model.Login) %>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Senha) %>
            </div>
            <div class="editor-field">
                <%= Html.PasswordFor(model => model.Senha)%>
                <%= Html.ValidationMessageFor(model => model.Senha) %>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Email) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Email) %>
                <%= Html.ValidationMessageFor(model => model.Email) %>
            </div>
            
            <p>
                <input type="submit" value="Cadastrar" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%= Html.ActionLink("Voltar", "LogIn") %>
    </div>

</asp:Content>

